﻿using System;
using System.Runtime.CompilerServices;
using System.Threading;
using UtilZ.Dotnet.Ex.Log;

namespace UtilZ.Dotnet.Ex.ZLog
{
    /// <summary>
    /// 用于内部记录日志的日志类
    /// </summary>
    public class ZLoger
    {
        private readonly static string _logerName = nameof(ZLoger);

        /// <summary>
        /// 是否输出到Loger,默认为None
        /// </summary>
        private static ZLogerOutputOptions _outputOption = ZLogerOutputOptions.Debug;
        /// <summary>
        /// 获取或设置是否启用输出到Loger,默认为None
        /// </summary>
        public static ZLogerOutputOptions OutputOption
        {
            get { return _outputOption; }
            set { _outputOption = value; }
        }


        private static Action<LogItem> _customer = null;
        /// <summary>
        /// 自定义日志输出
        /// </summary>
        public static Action<LogItem> Customer
        {
            get
            {
                return _customer;
            }
            set
            {
                _customer = value;
            }
        }


        /// <summary>
        /// TestZLogger
        /// </summary>
        public static void TestZLoger()
        {
            ZLoger.Trace("TestZLoger-Trace");
            ZLoger.Debug("TestZLoger-Debug");
            ZLoger.Info("TestZLoger-Info");
            ZLoger.Warn("TestZLoger-Warn");
            ZLoger.Error("TestZLoger-Error");
            ZLoger.Fatal("TestZLoger-Fatal");
        }


        #region 静态记录日志方法,默认日志快捷方法

        private static void Log(LogItem logItem)
        {
            try
            {
                logItem.LogerName = _logerName;
                switch (_outputOption)
                {
                    case ZLogerOutputOptions.Loger:
                        Loger.Log(logItem);
                        break;
                    case ZLogerOutputOptions.Customer:
                        _customer?.Invoke(logItem);
                        LogItem.Add(logItem);
                        break;
                    case ZLogerOutputOptions.Debug:
                    default:
                        System.Diagnostics.Debug.WriteLine(logItem.Message);
                        LogItem.Add(logItem);
                        break;
                }
            }
            catch (Exception exi)
            {
                LogSysInnerLog.OnRaiseLog(null, exi);
            }
        }


        #region Trace

        /// <summary>
        /// 追踪
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Trace(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Trace, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 追踪
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Trace(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Trace, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 追踪
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Trace(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Trace, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 追踪
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Trace(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Trace, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 追踪
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Trace(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Trace, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #region Debug

        /// <summary>
        /// 调试
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Debug(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Debug, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 调试
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Debug(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Debug, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 调试
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Debug(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Debug, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 调试
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Debug(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Debug, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 调试
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Debug(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Debug, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #region Info

        /// <summary>
        /// 信息
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Info(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Info, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 信息
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Info(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Info, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 信息
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Info(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Info, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 信息
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Info(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Info, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 信息
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Info(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Info, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #region Warn

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Warn(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Warn, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Warn(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Warn, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Warn(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Warn, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Warn(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Warn, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 警告
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Warn(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Warn, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #region Error

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Error(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Error, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Error(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Error, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Error(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Error, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Error(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Error, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Error(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Error, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #region Fatal

        /// <summary>
        /// 致命
        /// </summary>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Fatal(string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Fatal, LogConstant.DEFAULT_EVENT_ID, null, message, null);
            Log(item);
        }

        /// <summary>
        /// 致命
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Fatal(int eventId, object tag, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Fatal, eventId, null, message, tag);
            Log(item);
        }

        /// <summary>
        /// 致命
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Fatal(Exception ex, int eventId = LogConstant.DEFAULT_EVENT_ID, object tag = null, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Fatal, eventId, ex, null, tag);
            Log(item);
        }

        /// <summary>
        /// 致命
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Fatal(Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Fatal, LogConstant.DEFAULT_EVENT_ID, ex, message, null);
            Log(item);
        }

        /// <summary>
        /// 致命
        /// </summary>
        /// <param name="eventId">事件ID</param>
        /// <param name="tag">与对象关联的用户定义数据</param>
        /// <param name="ex">异常信息</param>
        /// <param name="message">日志消息</param>
        /// <param name="filePath">产生日志的代码文件</param>
        /// <param name="lineNum">产生日志在代码文件中的行数位置</param>
        /// <param name="memberName">产生日志的函数名</param>
        public static void Fatal(int eventId, object tag, Exception ex, string message, [CallerFilePath] string filePath = null, [CallerLineNumberAttribute] int lineNum = 0, [CallerMemberName] string memberName = null)
        {
            var item = LogItem.Take();
            item.Set(filePath, lineNum, memberName, DateTime.Now, Thread.CurrentThread, LogLevel.Fatal, eventId, ex, message, tag);
            Log(item);
        }

        #endregion

        #endregion
    }

    /// <summary>
    /// ZLoger输出选项
    /// </summary>
    public enum ZLogerOutputOptions
    {
        /// <summary>
        /// 调试输出
        /// </summary>
        Debug = 1,

        /// <summary>
        /// 输出到Loger
        /// </summary>
        Loger = 2,

        /// <summary>
        /// 自定义输出
        /// </summary>
        Customer = 3
    }


}
